/*
 * @Author: wwssaabb
 * @Date: 2021-09-04 16:52:54
 * @LastEditTime: 2021-09-04 16:58:30
 * @FilePath: \handwritten-code\main\create.js
 */

/* 
  实现Object.create(obj)
    作用：创建一个原型为obj的对象
*/

function createObj(obj) {
  function Fn() {}
  //将Fn构造函数的原型指向obj
  Fn.prototype = obj
  //返回新的实例对象
  return new Fn()
}

let a = {
  name: '张三',
  age: 20
}

let b = createObj(a)

let c = Object.create(a)

console.log(b instanceof Object) //true
console.log(c instanceof Object) //true